<?php
namespace app\index\controller;

use app\index\model\Member;
use think\Controller;
use think\Db;

class MemberController  extends  Controller
{
    public function index()
    {
        $data=Db::name('member')->paginate(3);
        //dump(input('name'));
       // dump(input('name'));
     // dump($this->request->param()) ;
		//dump($data);
	    $this->assign('list',$data);
      return $this->fetch();
    }

	public function getlist()
	{
		$data=Db::name('member')->field('id,name')->select();
		return ['data'=>$data];
    }

	public function deletebyid($id)
	{
		$id=$this->request->param('id');
Db::name('member')->where('id',$id)->delete();
$this->success('ok');
    }

	public function addMember()
	{
		return $this->fetch();
    }
	public function addMemberpost()
	{
		$member=new Member();
		$member->name=input('name');
		$member->phonenum=input('phonenum');
		$member->cardnum=input('cardnum');

		if ($member->save()) {
			return $this->success('操作成功!');
		}
		return $this->error('操作失败!');
    }

}
